/**
  ETFAna project, Anyang Normal University && IMP-CAS
  \class ETFTrackTa
  \brief class for a target-zone track, specifically the track downstream of the
  reaction target
  \author SUN Yazhou, asia.rabbit@163.com
  \since 2021-11-08
  \date 2021-11-30 last modified
  \attention
  changelog
  <table>
  <tr>  <th>Date         <th>Author      <th>Description                   </tr>
  <tr>  <td>2021-11-08   <td>Asia Sun    <td>file created                  </tr>
  </table>

  \copyright Copyright (c) 2021-2024 Anyang Normal U. && IMP-CAS with LGPLv3 LICENSE
*/

#include "ETFTrackTa.h"
#include "ETFMsg.h"

ETFTrackTa::ETFTrackTa() : ETFVTrack(){
  // TODO: CHIPD(in mm): user input configuration expected here
  fChiPD = 7.5;
  Initialize();
} // end ctor

// copy ctor
ETFTrackTa::ETFTrackTa(const ETFTrackTa &t) : ETFVTrack(t){
  *this = t;
} // end copy ctor
// assignment ctor
ETFTrackTa &ETFTrackTa::operator=(const ETFTrackTa &t){
  if(&t == this) return *this;

  ETFVTrack::operator=(t);
  return *this;
} // end member function operator=

ETFTrackTa::~ETFTrackTa(){}

void ETFTrackTa::SetId(int id, short type){
  const char xuv[] = {'X', 'Y'};
  fName = ETFMsg::Form("TrackTa%c #%d", xuv[type%2], id);
} // end member function SetId

int ETFTrackTa::EnoughHit(){
  return EnoughHit(fHits);
} // end member function EnoughHit

// the static version
int ETFTrackTa::EnoughHit(const map<int, ETFDCHit *> &hits){
  int n = 0; // number of valid hits
  for(auto &p : hits) if(p.second) n++;
  if(n >= 3) return n;
  return 0;
} // end member function EnoughHit
